<?php
/**
 * ================================================================
 * 
 *     /|    //| |     //   ) ) \\    / / //   ) ) 
 *    //|   // | |    ((         \\  / / ((        
 *   // |  //  | |      \\        \\/ /    \\      
 *  //  | //   | |        ) )      / /       ) )   
 * //   |//    | | ((___ / /      / / ((___ / /
 *     
 * HTTP & FTP Web File Manager
 * 
 * ================================================================
 * @package     msys-file-manager
 * @copyright   (c)2009 Hamdiya <hamdiya.dev@gmail.com>
 * @license     GNU General Public License {@link http://www.gnu.org/licenses/gpl.html}
 * @link        http://dir-list.sourceforge.net/
 * 
 * @copyright   (c)2011 Nuar H. Noah <nhnoah+msys@gmail.com>
 * @license     GNU Lesser GPL {@link http://www.gnu.org/licenses/lgpl.html}
 * @link        http://msys-file-manager.googlecode.com/
 * 
 * ================================================================
 * SVN revision information:
 * @version $Revision: 18 $:
 * @author  $Author: nhnoah $:
 * @date    $Date: 2011-11-21 14:52:15 +0000 (Mon, 21 Nov 2011) $:
 * ================================================================
 * 
 * @since   0.3.0
 */
function _is(&$check, $alternate = NULL){ 
    return (isset($check)) ? (empty($check) ? $alternate : $check) : $alternate; 
}

function get_base_uri($str, $type = false){
    
    $uri = BASE_URI;
    
    switch ($type){
        case 'admin': $uri = BASE_URI.'admin_login.php'; break;
        case 'css': $uri = CSS_URI; break;
        case 'js': $uri = JS_URI; break;
    }    
    return $uri.$str;    
}

function get_stylesheet_color_scheme_link(){    
    return get_base_uri('style-'._is($_SESSION['color_scheme_session'],0).'.css','css');
}

function get_header_title($url_folder){
    $str = "Index of: home/";
    return (empty($url_folder)) ? $str : $str.$url_folder."/"; 
}

function get_js_script($filename){
    return '<script type="text/javascript" src="'.get_base_uri($filename,'js').'"></script>'.PHP_EOL;
}

function _js_script($filename){
    echo get_js_script($filename);
}

function get_hash_uri($str){
    return base64_decode(trim($str));
}

function get_stats_info(array $numf, array $size){
    global $local_text;
    
    $total_found = count($numf);
    $total_size =  letter_size(array_sum($size));
    $ln_text = $local_text['consuming'];
    
    return sprintf( msyslang::STATS_INFO, $total_found, $ln_text, $total_size );
}

function show_stats_info(array $numf, array $size){
    echo get_stats_info($numf, $size);
}

function get_lang($str){
    global $local_text;
    return $local_text[$str];    
}

function _l($str){
    echo get_lang($str);
}

?>